﻿using BSU.Math.Algebra;

namespace BSU.Math.Geometry
{
    public class Matrix3D: Matrix
    {
        #region Constructors and initializers

        public Matrix3D():base(3, 3)
        {
        }

        public static Point3D operator *(Matrix3D matrix, Point3D point3D)
        {
            var x = point3D.InitialX * matrix[0, 0] +
                    point3D.InitialY * matrix[0, 1] +
                    point3D.InitialZ * matrix[0, 2];
            var y = point3D.InitialX * matrix[1, 0] +
                    point3D.InitialY * matrix[1, 1] +
                    point3D.InitialZ * matrix[1, 2];
            var z = point3D.InitialX * matrix[2, 0] +
                    point3D.InitialY * matrix[2, 1] +
                    point3D.InitialZ * matrix[2, 2];
            point3D.X = x;
            point3D.Y = y;
            point3D.Z = z;
            return point3D;
        }

        public static Matrix3D operator *(Matrix3D a, Matrix3D b)
        {
            Matrix c = (Matrix)a* (Matrix)b;
            Matrix3D d = new Matrix3D();

            for (int i = 0; i < a.M; i++)
            {
                for (int j = 0; j < b.N; j++)
                {
                    d[i, j] = c[i, j];
                }
            }

            return d;
        }

        #endregion
    }
}